<?php

namespace App\Admin\Controllers\Travel;

use App\Models\Travel\View;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class ViewController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '合作景点';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new View());

        $grid->column('id', __('ID'));
        $grid->column('viewname', __('viewname'));
        $grid->column('viewcontent', __('viewcontent'))->width('800');
        $grid->column('viewimg', __('viewimg'))->image();

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(View::findOrFail($id));



        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new View());

        $form->text('viewname',__('viewname'));
        $form->textarea('viewcontent',__('viewcontent'));
        $form->image('viewimg',__('viewimg'));
        return $form;
    }

    public function viewlist()
    {
        $a = [
            "total"=> 4,
            "per_page"=> 15,
            "current_page"=> 1,
            "last_page"=> 1,
            "next_page_url"=> null,
            "prev_page_url"=> null,
            "from"=> 1,
            "to"=> 3,
            "data"=> [
                [
                    "id"=> 9,
                    "text"=> "xxx"
                ],
                [
                    "id"=> 21,
                    "text"=> "xxx"
                ],
                [
                    "id"=> 42,
                    "text"=> "xxx"
                ],
                [
                    "id"=> 48,
                    "text"=> "xxx"
                ]
            ]
        ];
        return $a;
    }

}
